﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace CS490_Capstone___Stubby.Web_Pages
{
    public partial class Test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // read screen height passed through URL
            if (Request.QueryString.ToString() != "")
            {
                HtmlGenericControl testBody = (HtmlGenericControl)Page.Master.FindControl("myBody");
                // displays the appropriate header menu
                testBody.Attributes.Add("onload", "showJavaScriptHeader();");

                // sets browser height to the visible browser height as passed by the query string
                // sets browser height to minimum of 550px if browser height is smaller
                String browserHeight = (int.Parse(Request.QueryString["height"].ToString()) > 550) 
                    ? Request.QueryString["height"].ToString() : "550";

                // set the size of the input panel to fill the screen
                content.Height = int.Parse(browserHeight) - 120;
            }
            else
            // this block fires if JavaScript is not enabled or if the page is called without a height 
            // attribute, as at start up
            {
                // sets browser height to default 800px if browser height cannot be determined
                content.Height = int.Parse("800");
            }
        }

        protected void tableExample_Click(object sender, EventArgs e)
        {
            int s = 47;
            string[] tableString = new string[s];

            tableString[0] = "<table id='outputTable' class='results'>";
            tableString[1] = "  <tr>";
            tableString[2] = "    <td class='column'>";
            tableString[3] = "      <span>A</span>";
            tableString[4] = "    </td>";
            tableString[5] = "    <td class='column'>";
            tableString[6] = "      <span>B</span>";
            tableString[7] = "    </td>";
            tableString[8] = "    <td class='column'>";
            tableString[9] = "      <span>C</span>";
            tableString[10] = "    </td>";
            tableString[11] = "  </tr>";
            tableString[12] = "  <tr>";
            tableString[13] = "    <td>";
            tableString[14] = "      <span>&nbsp;cell A1&nbsp;</span>";
            tableString[15] = "    </td>";
            tableString[16] = "    <td>";
            tableString[17] = "      <span>&nbsp;cell B1&nbsp;</span>";
            tableString[18] = "    </td>";
            tableString[19] = "    <td>";
            tableString[20] = "      <span>&nbsp;cell C1&nbsp;</span>";
            tableString[21] = "    </td>";
            tableString[22] = "  </tr>";
            tableString[23] = "  <tr>";
            tableString[24] = "    <td>";
            tableString[25] = "      <span>&nbsp;cell A2&nbsp;</span>";
            tableString[26] = "    </td>";
            tableString[27] = "    <td>";
            tableString[28] = "      <span>&nbsp;cell B2&nbsp;</span>";
            tableString[29] = "    </td>";
            tableString[30] = "    <td>";
            tableString[31] = "      <span>&nbsp;cell C2&nbsp;</span>";
            tableString[32] = "    </td>";
            tableString[33] = "  </tr>";
            tableString[34] = "  <tr>";
            tableString[35] = "    <td>";
            tableString[36] = "      <span>&nbsp;cell A3&nbsp;</span>";
            tableString[37] = "    </td>";
            tableString[38] = "    <td>";
            tableString[39] = "      <span>&nbsp;cell B3&nbsp;</span>";
            tableString[40] = "    </td>";
            tableString[41] = "    <td>";
            tableString[42] = "      <span>&nbsp;cell C3&nbsp;</span>";
            tableString[43] = "    </td>";
            tableString[44] = "  </tr>";
            tableString[45] = "</table>";
            tableString[46] = "<br />";

            for (int i = 0; i < s; i++)
            {
                resultsTableExample.InnerHtml += tableString[i];
            }
        }
    }
}